package cn.lei.uicontrols;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

    private ArrayAdapter<listCellData> mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mAdapter = new ArrayAdapter<listCellData>(this, android.R.layout.simple_list_item_1);
        setListAdapter(mAdapter);

        mAdapter.add(new listCellData("RadioGroup", this, new Intent(this, AtyUsingRadioGroup.class)));
        mAdapter.add(new listCellData("CheckBox", this, new Intent(this, AtyUsingCheckBox.class)));
        mAdapter.add(new listCellData("DataPicker", this, new Intent(this, AtyUsingDataPicker.class)));
        mAdapter.add(new listCellData("TimePicker", this, new Intent(this, AtyUsingTimerPicker.class)));
        mAdapter.add(new listCellData("Spinner", this, new Intent(this, AtyUsingSpinner.class)));
        mAdapter.add(new listCellData("ProgressBar", this, new Intent(this, AtyUsingProgressBar.class)));
        mAdapter.add(new listCellData("AutoCompleteTextView", this, new Intent(this, AtyUsingAutoCompleteTextView.class)));
        mAdapter.add(new listCellData("SeekBar", this, new Intent(this, AtyUsingSeekBar.class)));
        mAdapter.add(new listCellData("GridView", this, new Intent(this, AtyUsingGridView.class)));
        mAdapter.add(new listCellData("ProgressDialog", this, new Intent(this, AtyUsingProgressDialog.class)));
        mAdapter.add(new listCellData("Notification", this, new Intent(this, AtyUsingNotification.class)));
        mAdapter.add(new listCellData("ScrollView", this, new Intent(this, AtyUsingScrollView.class)));
        mAdapter.add(new listCellData("RatingBar", this, new Intent(this, AtyUsingRatingBar.class)));
        mAdapter.add(new listCellData("ImageSwitcher", this, new Intent(this, AtyUsingImageSwitcher.class)));
        mAdapter.add(new listCellData("Gallery", this, new Intent(this, AtyUsingGallery.class)));
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        listCellData data = mAdapter.getItem(position);
        data.startActivity();

        super.onListItemClick(l, v, position, id);
    }
}
